package com.yinhai.redis.cluster.event.filter;

import junit.framework.Assert;

import com.yinhai.redis.cluster.event.Event;

public class NotEventFilter implements EventFilter {

	private EventFilter filter;
	
	public NotEventFilter(EventFilter filter) {
		this.filter = filter;
	}

	@Override
	public boolean match(Event event) {
		Assert.assertNotNull(filter);
		return !filter.match(event);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((filter == null) ? 0 : filter.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final NotEventFilter other = (NotEventFilter) obj;
		if (filter == null) {
			if (other.filter != null)
				return false;
		} else if (!filter.equals(other.filter))
			return false;
		return true;
	}
	
	

}
